package com.module.imagelib.glide.progress;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.LibraryGlideModule;

import java.io.InputStream;

/**
 * okhttp组件
 * 参考：https://blog.csdn.net/guolin_blog/article/details/78357251
 * 参考：https://blog.csdn.net/androidstarjack/article/details/75042070
 * Created by dell on 2018/6/25
 */

@GlideModule
public class OkHttpGlideModule extends LibraryGlideModule {

    /**
     * 用于实现加载时显示进度条
     * @param context
     * @param glide
     * @param registry
     */
    public void registerComponents(Context context, Glide glide, Registry registry) {
        registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(ProgressManager.getOkHttpClient()));
    }
}
